package com.hxkj.domain.enums;

import com.platform.common.domain.exception.CustomExceptionCode;

/**
 * 用户异常枚举
 * <p>
 * Created by chenwei on 2017/6/21.
 */
public enum UserExceptionEnum implements CustomExceptionCode {
    TOKEN_NOT_EXIST(600, "用户未登录", 401),
    TOKEN_NOT_VALID(604, "你的登录信息已过期，请重新登录", 401),
    TOKEN_EXPIRES_CODE(601, "用户信息已过期", 401),
    USER_MOBILE_DISABLE(602, "用户已经禁用", 401),
    UNAUTHORIZED(603, "未授权", 401),
    USER_ACCOUNT_IS_NULL(300, "账号/密码为不能为空", 900),
    USER_SERVICE_REQUEST_FAIL(301, "服务请求超时", 900),
    USER_NOT_EXIST(302, "用户不存在", 900),
    PLEASE_SELECT_FUNCTION(303, "请选择功能", 900),
    PLEASE_SELECT_ROLE(304, "请选择角色", 900),
    PLEASE_SELECT_SITE(305, "请选择站点", 900),
    SITE_NOT_EXIST(306, "站点id为空", 900),
    PLEASE_SELECT_USER(307,"请选择用户",900),
    USER_NOT_DELETE_ADMIN(308,"超级管理员无法删除",900),
    USER_ARE_EXIST(309,"该用户已存在",900),
    USER_NOT_UID(310,"该用户ID为空",900),
    USER_NOT_UPDATE_ADMIN(311,"超级管理员无法修改",900),
    SITE_NOT_MSG(312, "站点不存在", 900),
    GET_ROLE_BY_ACCOUNT_FAIL(313, "通过账户获取角色异常", 900),
    GET_FUNCTION_BY_ACCOUNT_FAIL(314, "通过账户获取功能异常", 900),
    GET_MENU_BY_ACCOUNT_FAIL(315, "通过账户获取功能异常", 900),
    ADMIN_NOT_SITE(320, "超级管理员无法分配站点", 900),
    GET_USER_BY_ID_FAIL(316,"通过id获取用户信息失败",900),
    GET_USER_BY_TOKEN_FAIL(317,"登录状态过期",900),
    ACCESSTOKEN_NOT_EXIST(318,"accesstoken不存在",900),
    ACCOUNT_ERROR(319,"账号或密码错误",900),
    SITE_TO_USER_ERROR(321,"用户分配站点失败",900),
    GET_USER_SITE_ERROR(322,"获取用户站点失败",900),
    UPDATE_USER_ERROR(323,"修改用户失败",900),
    DELETE_USER_ERROR(324,"删除用户失败",900),
    STOP_USER_NOT_SITE(325,"停用用户无法分配站点",900),
    SUBSITE_NOT_SITE(326,"子站无法分配站点",900),
    NO_ADMIN_NOT_SITE(327,"不是超级管理员无法分配站点",900),
    ROLE_ONLY_ONE_USER(328,"一个角色只能关联一个账号",900),
    ROLE_ASSIGN_USER_ERROR(329,"用户关联角色失败",900),
    VALIDATECODE_IS_ERROR(330,"验证码输入错误",900),
    LOGIN_FORBIDEN(331,"验证码输入错误次数超过5次,请联系管理员",900),
    REQUIRE_VALIDATECODE(332,"请先输入验证码",900),
    ACCOUNT_IS_LOCK(333,"账户已被锁定,请10分钟后再操作",900),
    USER_SITE_NOT_NULL(334,"用户站点分配不能为空",900),
    USER_PASSWORD_NOT_NULL(335,"用户密码不能为空",900),
    USER_NAME_NOT_NULL(335,"用户姓名不能为空",900),
    USER_ACCOUNT_NOT_NULL(335,"用户账号不能为空",900),
    USER_PASSWORD_IS_NO(336,"原用户密码不正确",900),
    UPDATE_PASSWORD_ERROR(337,"修改密码失败",900),
    USER_EMAIL_IS_NULL(338, "用户邮箱为空", 900),
    USER_PHONE_IS_NULL(339, "用户电话为空", 900),
    USER_LOGIN_INFO_INVAILD(340, "用户登录信息不正确", 900),
    VALIDATECODE_INVALID(341, "验证码已过期", 900),
    USERINFO_INVALID(342, "用户信息不完整", 900),
    USER_NOT_ACTIVE(343, "用户未激活，已发送激活邮件", 900),
    USER_ACTIVATED(344, "用户已激活", 900),
    SEND_MSG_IS_NULL(345, "发送内容为空", 900),
    EMAIL_MSG_IS_NULL(346, "发送邮件内容为空", 900),
    FORWARD_URL_IS_NULL(347, "跳转网站地址为空", 900),
    COLLECT_SITE_IS_NULL(348, "收藏站点信息为空", 900),
    COLLECT_SITE_REPEAT(349, "站点重复收藏", 900),
    CANCEL_SITE_IS_NULL(350, "取消收藏站点信息为空", 900),
    PHONE_BE_USED(351, "手机号已被使用", 900),
    EMAIL_BE_USED(352, "邮箱已被使用", 900)


    /*USER_ACCOUNT_IS_NULL(300, "账号/密码为不能为空", 900),
    USER_SERVICE_REQUEST_FAIL(301, "服务请求超时", 900),
    USER_NOT_EXIST(302, "用户不存在", 900),
    PLEASE_SELECT_FUNCTION(303, "请选择功能", 900),
    PLEASE_SELECT_ROLE(304, "请选择角色", 900),
    PLEASE_SELECT_SITE(305, "请选择站点", 900),
    SITE_NOT_EXIST(306, "站点id为空", 900),
    PLEASE_SELECT_USER(307,"请选择用户",900),
    USER_NOT_DELETE_ADMIN(308,"超级管理员无法删除",900),
    USER_ARE_EXIST(309,"该用户已存在",900),
    USER_NOT_UID(310,"该用户ID为空",900),
    USER_NOT_UPDATE_ADMIN(311,"超级管理员无法修改",900),
    SITE_NOT_MSG(312, "站点不存在", 900),
    GET_ROLE_BY_ACCOUNT_FAIL(313, "通过账户获取角色异常", 900),
    GET_FUNCTION_BY_ACCOUNT_FAIL(314, "通过账户获取功能异常", 900),
    GET_MENU_BY_ACCOUNT_FAIL(315, "通过账户获取功能异常", 900),
    ADMIN_NOT_SITE(320, "超级管理员无法分配站点", 900),
    GET_USER_BY_ID_FAIL(316,"用户服务不可用",900),
    GET_USER_BY_TOKEN_FAIL(317,"通过token获取用户信息失败",900),
    GET_USER_BY_ID_FAIL(316,"通过id获取用户信息失败",900),
    GET_USER_BY_TOKEN_FAIL(317,"登录状态过期",900),
    ACCESSTOKEN_NOT_EXIST(318,"accesstoken不存在",900),
    ACCOUNT_ERROR(319,"账号或密码错误",900),
    SITE_TO_USER_ERROR(321,"用户分配站点失败",900),
    GET_USER_SITE_ERROR(322,"获取用户站点失败",900),
    UPDATE_USER_ERROR(323,"修改用户失败",900),
    DELETE_USER_ERROR(324,"删除用户失败",900),
    STOP_USER_NOT_SITE(325,"停用用户无法分配站点",900),
    SUBSITE_NOT_SITE(326,"子站无法分配站点",900),
    NO_ADMIN_NOT_SITE(327,"不是超级管理员无法分配站点",900),
    ROLE_ONLY_ONE_USER(328,"一个角色只能关联一个账号",900),
    ROLE_ASSIGN_USER_ERROR(329,"用户关联角色失败",900),
    VALIDATECODE_IS_ERROR(330,"验证码输入错误",900),
    LOGIN_FORBIDEN(331,"验证码输入错误次数超过5次,请联系管理员",900),
    REQUIRE_VALIDATECODE(332,"请先输入验证码",900),
    ACCOUNT_IS_LOCK(333,"账户已被锁定,请10分钟后再操作",900),
    USER_SITE_NOT_NULL(334,"用户站点分配不能为空",900),
    USER_PASSWORD_NOT_NULL(335,"用户密码不能为空",900),
    USER_NAME_NOT_NULL(335,"用户姓名不能为空",900),
    USER_ACCOUNT_NOT_NULL(335,"用户账号不能为空",900),
    USER_PASSWORD_IS_NO(336,"原用户密码不正确",900),
    UPDATE_PASSWORD_ERROR(337,"修改密码失败",900),
    USER_EMAIL_IS_NULL(338, "用户邮箱为空", 900),
    USER_PHONE_IS_NULL(339, "用户电话为空", 900),
    USER_LOGIN_INFO_INVAILD(340, "用户登录信息不正确", 900),
    VALIDATECODE_INVALID(341, "验证码已过期", 900),
    USERINFO_INVALID(342, "用户信息不完整", 900),
    USER_NOT_ACTIVE(343, "用户未激活，已发送激活邮件", 900),
    USER_ACTIVATED(344, "用户已激活", 900),
    SEND_MSG_IS_NULL(345, "发送内容为空", 900),
    EMAIL_MSG_IS_NULL(346, "发送邮件内容为空", 900),
    FORWARD_URL_IS_NULL(347, "跳转网站地址为空", 900),
    COLLECT_SITE_IS_NULL(348, "收藏站点信息为空", 900),
    COLLECT_SITE_REPEAT(349, "站点重复收藏", 900),
    CANCEL_SITE_IS_NULL(350, "取消收藏站点信息为空", 900),
    ACCOUUT_ERROR(319,"账号或密码错误",900),


//    USER_ACCOUNT_IS_NULL(300, "账号/密码为不能为空", 900),
//    USER_SERVICE_REQUEST_FAIL(301, "服务请求超时", 900),
//    USER_NOT_EXIST(302, "用户不存在", 900),
//    PLEASE_SELECT_FUNCTION(303, "请选择功能", 900),
//    PLEASE_SELECT_ROLE(304, "请选择角色", 900),
//    PLEASE_SELECT_SITE(305, "请选择站点", 900),
//    SITE_NOT_EXIST(306, "站点id为空", 900),
//    PLEASE_SELECT_USER(307,"请选择用户",900),
//    USER_NOT_DELETE_ADMIN(308,"超级管理员无法删除",900),
//    USER_ARE_EXIST(309,"该用户已存在",900),
//    USER_NOT_UID(310,"该用户ID为空",900),
//    USER_NOT_UPDATE_ADMIN(311,"超级管理员无法修改",900),
//    SITE_NOT_MSG(312, "站点不存在", 900),
//    GET_ROLE_BY_ACCOUNT_FAIL(313, "通过账户获取角色异常", 900),
//    GET_FUNCTION_BY_ACCOUNT_FAIL(314, "通过账户获取功能异常", 900),
//    GET_MENU_BY_ACCOUNT_FAIL(315, "通过账户获取功能异常", 900),
//    ADMIN_NOT_SITE(320, "超级管理员无法分配站点", 900),
//    GET_USER_BY_ID_FAIL(316,"用户服务不可用",900),
//    GET_USER_BY_TOKEN_FAIL(317,"通过token获取用户信息失败",900),
//    ACCESSTOKEN_NOT_EXIST(318,"accesstoken不存在",900),
//
//    SITE_TO_USER_ERROR(321,"用户分配站点失败",900),
//    GET_USER_SITE_ERROR(322,"获取用户站点失败",900),
//    UPDATE_USER_ERROR(323,"修改用户失败",900),
//    DELETE_USER_ERROR(324,"删除用户失败",900),
//    STOP_USER_NOT_SITE(325,"停用用户无法分配站点",900),
//    SUBSITE_NOT_SITE(326,"子站无法分配站点",900),
//    NO_ADMIN_NOT_SITE(327,"不是超级管理员无法分配站点",900),
//    ROLE_ONLY_ONE_USER(328,"一个角色只能关联一个账号",900),
//    ROLE_ASSIGN_USER_ERROR(329,"用户关联角色失败",900),
//    VALIDATECODE_IS_ERROR(330,"验证码输入错误",900),
//    LOGIN_FORBIDEN(331,"验证码输入错误次数超过5次,请联系管理员",900),
//    REQUIRE_VALIDATECODE(332,"请先输入验证码",900),
//    ACCOUNT_IS_LOCK(333,"账户已被锁定,请10分钟后再操作",900),
//    USER_SITE_NOT_NULL(334,"用户站点分配不能为空",900),
//    USER_PASSWORD_NOT_NULL(335,"用户密码不能为空",900),
//    USER_NAME_NOT_NULL(335,"用户姓名不能为空",900),
//    USER_ACCOUNT_NOT_NULL(335,"用户账号不能为空",900),
//    USER_PASSWORD_IS_NO(336,"原用户密码不正确",900),
//    UPDATE_PASSWORD_ERROR(327,"修改密码失败",900),
    UPDATE_PASSWORD_ERROR(327,"修改密码失败",900),*/

    ;


    private Integer code;
    private String msg;
    private Integer httpCode;

    UserExceptionEnum(Integer code, String msg, Integer httpCode) {
        this.code = code;
        this.msg = msg;
        this.httpCode = httpCode;
    }

    @Override
    public Integer getCode() {
        return code;
    }

    @Override
    public void setCode(Integer code) {
        this.code = code;
    }

    @Override
    public String getMsg() {
        return msg;
    }

    @Override
    public void setMsg(String msg) {
        this.msg = msg;
    }

    @Override
    public Integer getHttpCode() {
        return httpCode;
    }

    @Override
    public void setHttpCode(Integer httpCode) {
        this.httpCode = httpCode;
    }


    public static UserExceptionEnum getEnumByCode(Integer code){
        for(UserExceptionEnum userExceptionEnum : UserExceptionEnum.values()){
            if(code.equals(userExceptionEnum.getCode())){
                return userExceptionEnum;
            }
        }
        return null;
    }
}
